<template>
  <div class="homeswiper">
    <swiper>
      <swiper-item v-for="item, index in banners" :key="index">
        <a :href="item.link">
          <img :src="item.image" @load="imageLoad">
        </a>
      </swiper-item>
    </swiper>
  </div>
</template>

<script lang="js">
// 导入轮播图
import { Swiper, SwiperItem } from '@/components/common/swiper/index.js'
export default {
  name: 'HomeSwiper',
  components: {
    Swiper,
    SwiperItem,
  },
  data() {
    return {
      isLoad: false
    }
  },
  props: {
    banners: {
      type: Array,
      default() {
        return []
      }
    }
  },
  methods: {
    // 图片完全加载后 开始正常刷新
    // 将图片正常进行加载
    imageLoad() {
      if (!this.isLoad) {
        this.$emit('swiperImageLoad')
        this.isLoad = true
      }
    }
  }
}
</script>

<style scoped></style>